package org.dxy.service.impl;

import org.dxy.entity.Trip;
import org.dxy.Mapper.TripMapper;
import org.dxy.service.TripService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

// 车次服务实现类
@Service
public class TripServiceImpl implements TripService {
    @Autowired
    private TripService tripService;

    @Override
    public Trip addTrip(Trip trip) {
        return tripService.save(trip);
    }

    @Override
    public Trip updateTrip(Trip trip) {
        return tripMapper.save(trip);
    }

    @Override
    public void deleteTrip(Long id) {
        tripMapper.deleteById(id);
    }

    @Override
    public List<Trip> searchTrips(String departure, String destination, LocalDateTime departureTime) {
        return tripMapper.findByDepartureAndDestinationAndDepartureTimeGreaterThanEqual(departure, destination, departureTime);
    }
}
